Skip to content

refactor(hugrv2)!: Rename Terms to clarify (runtime) Types from static parameter Kinds#3019

Open
acl-cqc wants to merge 7 commits into
mainfrom
acl/rename_type_kind
Open

refactor(hugrv2)!: Rename Terms to clarify (runtime) Types from static parameter Kinds#3019
acl-cqc wants to merge 7 commits into
mainfrom
acl/rename_type_kind

Conversation

@acl-cqc
Copy link
Copy Markdown
Contributor

@acl-cqc acl-cqc commented Apr 7, 2026

[Note: this will textually conflict with #3022, will have to merge whichever is approved second but I think should b straightforward.]

Using Type to mean a static parameter (that accepts a static Term argument) is confusing; instead keep Type as meaning a type of runtime values

  • Term::RuntimeType becomes Term::TypeKind
  • Term::XXXType becomes Term:::XXXKind (e.g. StringType -> StringKind, ListType -> ListKind)
  • Term::RuntimeXXX becomes Term::XXXType (e.g. Term::RuntimeExtension -> Term::ExtensionType)
  • check_term_type -> check_term_kind

TermTypeError -> TermKindError to follow in another PR.

BREAKING CHANGE: many renames of variants of Term; ...Types are now Kinds, Runtime... are now Types. Also check_term_type is now check_term_kind

@acl-cqc acl-cqc changed the title Acl/rename type kind refactor(hugrv2)!: Rename Terms to distinguish (runtime) Types from static parameter Kinds Apr 7, 2026
@acl-cqc acl-cqc changed the title refactor(hugrv2)!: Rename Terms to distinguish (runtime) Types from static parameter Kinds refactor(hugrv2)!: Rename Terms to clarify (runtime) Types from static parameter Kinds Apr 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.09%. Comparing base (90a165e) to head (98e1cea).

Files with missing lines Patch % Lines
hugr-core/src/types/type_param.rs 69.76% 39 Missing ⚠️
hugr-core/src/types/serialize.rs 84.00% 4 Missing ⚠️
hugr-core/src/extension/op_def.rs 25.00% 0 Missing and 3 partials ⚠️
hugr-core/src/extension/resolution/types.rs 57.14% 3 Missing ⚠️
hugr-core/src/extension/resolution/types_mut.rs 57.14% 3 Missing ⚠️
hugr-core/src/import.rs 66.66% 2 Missing and 1 partial ⚠️
hugr-core/src/export.rs 83.33% 2 Missing ⚠️
hugr-core/src/extension/type_def.rs 75.00% 1 Missing ⚠️
hugr-core/src/types.rs 90.00% 0 Missing and 1 partial ⚠️
hugr-core/src/types/type_row.rs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3019      +/-   ##
==========================================
- Coverage   81.09%   81.09%   -0.01%     
==========================================
  Files         241      241              
  Lines       45054    45050       -4     
  Branches    38822    38818       -4     
==========================================
- Hits        36536    36532       -4     
  Misses       6542     6542              
  Partials     1976     1976              
Flag Coverage Δ
python 88.89% <ø> (ø)
rust 79.83% <76.92%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 28, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 6 skipped benchmarks1


Comparing acl/rename_type_kind (98e1cea) with main (90a165e)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@acl-cqc acl-cqc changed the base branch from acl/type_wraps_term to acl/boundless_type April 28, 2026 11:07
@acl-cqc acl-cqc force-pushed the acl/boundless_type branch from 2dec804 to b45e61f Compare May 5, 2026 12:48
@hugrbot
Copy link
Copy Markdown
Collaborator

hugrbot commented May 5, 2026

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building hugr v0.27.1 (current)
     Built [  34.613s] (current)
   Parsing hugr v0.27.1 (current)
    Parsed [   0.004s] (current)
  Building hugr v0.27.1 (baseline)
     Built [  34.482s] (baseline)
   Parsing hugr v0.27.1 (baseline)
    Parsed [   0.004s] (baseline)
  Checking hugr v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.011s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  70.418s] hugr
  Building hugr-cli v0.27.1 (current)
     Built [  28.384s] (current)
   Parsing hugr-cli v0.27.1 (current)
    Parsed [   0.006s] (current)
  Building hugr-cli v0.27.1 (baseline)
     Built [  28.495s] (baseline)
   Parsing hugr-cli v0.27.1 (baseline)
    Parsed [   0.006s] (baseline)
  Checking hugr-cli v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.015s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  58.766s] hugr-cli
  Building hugr-core v0.27.1 (current)
     Built [  24.546s] (current)
   Parsing hugr-core v0.27.1 (current)
    Parsed [   0.088s] (current)
  Building hugr-core v0.27.1 (baseline)
     Built [  24.603s] (baseline)
   Parsing hugr-core v0.27.1 (baseline)
    Parsed [   0.081s] (baseline)
  Checking hugr-core v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.222s] 196 checks: 193 pass, 3 fail, 0 warn, 56 skip

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/enum_variant_missing.ron

Failed in:
variant Term::RuntimeType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:87
variant Term::StaticType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:89
variant Term::BoundedNatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:95
variant Term::StringType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:97
variant Term::BytesType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:99
variant Term::FloatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:101
variant Term::ListType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:105
variant Term::TupleType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:108
variant Term::RuntimeExtension, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:115
variant Term::RuntimeFunction, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:121
variant Term::RuntimeSum, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:125
variant Term::ConstType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:173
variant Term::RuntimeType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:87
variant Term::StaticType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:89
variant Term::BoundedNatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:95
variant Term::StringType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:97
variant Term::BytesType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:99
variant Term::FloatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:101
variant Term::ListType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:105
variant Term::TupleType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:108
variant Term::RuntimeExtension, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:115
variant Term::RuntimeFunction, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:121
variant Term::RuntimeSum, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:125
variant Term::ConstType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:173
variant Term::RuntimeType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:87
variant Term::StaticType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:89
variant Term::BoundedNatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:95
variant Term::StringType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:97
variant Term::BytesType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:99
variant Term::FloatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:101
variant Term::ListType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:105
variant Term::TupleType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:108
variant Term::RuntimeExtension, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:115
variant Term::RuntimeFunction, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:121
variant Term::RuntimeSum, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:125
variant Term::ConstType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:173
variant Term::RuntimeType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:87
variant Term::StaticType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:89
variant Term::BoundedNatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:95
variant Term::StringType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:97
variant Term::BytesType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:99
variant Term::FloatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:101
variant Term::ListType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:105
variant Term::TupleType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:108
variant Term::RuntimeExtension, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:115
variant Term::RuntimeFunction, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:121
variant Term::RuntimeSum, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:125
variant Term::ConstType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:173
variant Term::RuntimeType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:87
variant Term::StaticType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:89
variant Term::BoundedNatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:95
variant Term::StringType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:97
variant Term::BytesType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:99
variant Term::FloatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:101
variant Term::ListType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:105
variant Term::TupleType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:108
variant Term::RuntimeExtension, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:115
variant Term::RuntimeFunction, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:121
variant Term::RuntimeSum, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:125
variant Term::ConstType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:173

--- failure function_missing: pub fn removed or renamed ---

Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function itself may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/function_missing.ron

Failed in:
function hugr_core::types::type_param::check_term_types, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:796
function hugr_core::types::type_param::check_term_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:727

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/inherent_method_missing.ron

Failed in:
Term::max_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:182
Term::bounded_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:188
Term::new_list_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:198
Term::new_tuple_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:203
Term::max_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:182
Term::bounded_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:188
Term::new_list_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:198
Term::new_tuple_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:203
Term::max_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:182
Term::bounded_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:188
Term::new_list_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:198
Term::new_tuple_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:203
Term::max_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:182
Term::bounded_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:188
Term::new_list_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:198
Term::new_tuple_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:203
Term::max_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:182
Term::bounded_nat_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:188
Term::new_list_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:198
Term::new_tuple_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:203

   Summary semver requires new major version: 3 major and 0 minor checks failed
  Finished [  50.439s] hugr-core
  Building hugr-llvm v0.27.1 (current)
     Built [  28.913s] (current)
   Parsing hugr-llvm v0.27.1 (current)
    Parsed [   0.012s] (current)
  Building hugr-llvm v0.27.1 (baseline)
     Built [  29.111s] (baseline)
   Parsing hugr-llvm v0.27.1 (baseline)
    Parsed [   0.012s] (baseline)
  Checking hugr-llvm v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.039s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  59.121s] hugr-llvm
  Building hugr-model v0.27.1 (current)
     Built [  10.539s] (current)
   Parsing hugr-model v0.27.1 (current)
    Parsed [   0.017s] (current)
  Building hugr-model v0.27.1 (baseline)
     Built [  10.547s] (baseline)
   Parsing hugr-model v0.27.1 (baseline)
    Parsed [   0.016s] (baseline)
  Checking hugr-model v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.029s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  21.881s] hugr-model
  Building hugr-persistent v0.6.1 (current)
     Built [  22.015s] (current)
   Parsing hugr-persistent v0.6.1 (current)
    Parsed [   0.008s] (current)
  Building hugr-persistent v0.6.1 (baseline)
     Built [  22.737s] (baseline)
   Parsing hugr-persistent v0.6.1 (baseline)
    Parsed [   0.008s] (baseline)
  Checking hugr-persistent v0.6.1 -> v0.6.1 (assume minor change)
   Checked [   0.012s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  45.525s] hugr-persistent

@acl-cqc acl-cqc force-pushed the acl/rename_type_kind branch from 45f1367 to 6ea5e65 Compare May 5, 2026 14:36
@acl-cqc acl-cqc changed the base branch from acl/boundless_type to main May 5, 2026 14:41
@acl-cqc acl-cqc marked this pull request as ready for review May 5, 2026 14:44
@acl-cqc acl-cqc requested a review from a team as a code owner May 5, 2026 14:44
@acl-cqc acl-cqc requested a review from cqc-alec May 5, 2026 14:44
Copy link
Copy Markdown
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Should we also change TermTypeError::TypeMismatch { term, type_} to TermTypeError::KindMismatch {value, kind}? I guess we should??

Yes I guess we should do that as well.

@acl-cqc
Copy link
Copy Markdown
Contributor Author

acl-cqc commented May 11, 2026

Thanks!

Should we also change TermTypeError::TypeMismatch { term, type_} to TermTypeError::KindMismatch {value, kind}? I guess we should??

Yes I guess we should do that as well.

I am gonna do that as a followup because I realize there is also TermTypeError (=> TermKindError?)

@acl-cqc acl-cqc enabled auto-merge May 11, 2026 14:16
@acl-cqc acl-cqc disabled auto-merge May 11, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants